package main

import (
	"fmt"
	"sync"
	_ "time"
)

var (
	result = make(map[uint64]uint64,10)
	lock sync.Mutex  //全局互斥锁
)

func test(n uint64)  {
	
	var res uint64 = 1
	var i uint64
	for i=1;i<=n;i++ {
		res *= i
	}
	lock.Lock()
	result[n] = res
	lock.Unlock()
}

func main()  {
	var i uint64
	for i=1;i<=200;i++ {
		go test(i)
	}	

	//time.Sleep(time.Second*100)

	lock.Lock()
	for i=1;i<=uint64(len(result));i++ {
		fmt.Printf("map[%d]=%d\n",i,result[i])
	}
	lock.Unlock()
}
